import request from '@/utils/request'
import {POS_SERVER_URL} from '@/utils/common'
import {getSignedParams} from '@/utils/sign'
import store from '../store'

// 用户登录
export function login (data) {
  return request({
    url: POS_SERVER_URL + '/api/pos-client/login',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 获取最新班次
export function latestShift (stationId) {
  return request({
    url: POS_SERVER_URL + '/api/pos-client/shift/latest',
    method: 'post',
    data: getSignedParams({stationId: stationId})
  })
}

// 交班
export function handover () {
  return request({
    url: POS_SERVER_URL + '/api/pos-client/shift/handover',
    method: 'post',
    data: getSignedParams({stationId: store.getters.stationId, operator: store.getters.operator})
  })
}

// 获取当班报表
export function shiftReport (stationId) {
  return request({
    url: POS_SERVER_URL + '/api/pos-client/shift/report',
    method: 'post',
    data: getSignedParams({stationId: stationId})
  })
}

// 测试-新增加油记录
export function addFuelRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/add',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 测试-锁定加油记录
export function lockFuelRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/lock',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 检查是否拥有该权限
export function checkPermission (data) {
  return request({
    url: POS_SERVER_URL + '/api/pos-client/permission/check',
    method: 'post',
    data: getSignedParams(data)
  })
}
